package com.aya.data.decorate.decorateimpl;

import com.aya.data.decorate.IGoods;
import com.aya.data.decorate.impl.Goods;

import java.math.BigDecimal;
import java.math.RoundingMode;

public class Discount extends GoodsDecorator {
    public Discount(IGoods goods, BigDecimal ratio) {
        this.goods = goods;
        this.ratio = ratio;
    }

    private IGoods goods;
    private BigDecimal ratio;

    @Override
    public BigDecimal price() {
        return goods.price().multiply(ratio.divide(BigDecimal.valueOf(10),2, RoundingMode.DOWN));
    }
}
